package com.haima.sage.bigdata.api.common;

import java.io.Closeable;
import java.io.IOException;
import java.util.concurrent.TimeUnit;

public class CleanHandle implements Runnable {
    private Closeable obj;

    public CleanHandle(Closeable obj) {
        this.obj = obj;
    }


    @Override
    public void run() {
        try {
            TimeUnit.SECONDS.sleep(30);
        } catch (InterruptedException e) {

        } finally {
            close();
        }
    }

    private void close() {
        if (obj != null) {
            try {
                obj.close();
            } catch (IOException e) {

            }
        }
    }
}
